package nongchang.kuaijiecaifu.com.ncapp_android.ui;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ezy.lite.util.FragmentUtil;
import ezy.lite.util.Param;
import nongchang.kuaijiecaifu.com.ncapp_android.Const;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.activity.BaseActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.fragment.MyLaiseeFragment;

public class MyLaiseeActivity extends BaseActivity {
    @BindView(R.id.types)
    TabLayout mTabs;
    @BindView(R.id.pager)
    ViewPager mViewPager;

    private FragmentPagerAdapter fpa = new FragmentPagerAdapter(getSupportFragmentManager()) {
        private String[] titles = Const.LAISEE_TITLE;
        @Override
        public Fragment getItem(int position) {

            return FragmentUtil.newInstance(MyLaiseeFragment.class, Param.bundle(position));
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }

        @Override
        public int getCount() {
            return titles.length;
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_laisee);
        ButterKnife.bind(this);
        mViewPager.setAdapter(fpa);
        mTabs.setupWithViewPager(mViewPager);
        mTabs.getTabAt(0).select();
    }
    @OnClick({R.id.btn_back})
    void onClick(View view){
        switch (view.getId()){
            case R.id.btn_back:
                finish();
                break;
        }
    }
}
